package com.daocao.ds.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.daocao.ds.R;
import com.daocao.ds.api.model.DealDetailModel;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by xsooy-pc on 2017/10/23.
 */

public class LoanerInfoTotalAdapter extends ItemAdapter<DealDetailModel.DatasBean.BaseInfoBean, LoanerInfoTotalAdapter.DefaultHolder> {

    private Context context;

    public LoanerInfoTotalAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public DefaultHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DefaultHolder(inflate(R.layout.item_loaner_info_total, parent));
    }

    @Override
    public void onBindViewHolder(DefaultHolder holder, int position) {
        DealDetailModel.DatasBean.BaseInfoBean item = getItem(position);
        holder.txtTitle.setText(item.title);
        LoanerInfoAdapter adapter = new LoanerInfoAdapter(context);
        holder.list.setAdapter(adapter);
        holder.list.setNestedScrollingEnabled(false);
        adapter.update(item.lists);
    }

    class DefaultHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.txt_title)
        TextView txtTitle;
        @BindView(R.id.list)
        RecyclerView list;

        public DefaultHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    private OnChooseListener onChooseListener;

    public void setOnChooseListener(OnChooseListener onChooseListener) {
        this.onChooseListener = onChooseListener;
    }

    public interface OnChooseListener {
        void onSuccess();
    }
}
